cmake_minimum_required( VERSION 2.8 )
project( go1_trans_c )


find_package(OpenCV 4 REQUIRED)
if(OpenCV_FOUND)
    include_directories(${OpenCV_INCLUDE_DIR})
    message(STATUS "OpenCV ${OpenCV_VERSION} FOUND")
    message(STATUS ${OpenCV_LIBS})
    if(${OpenCV_VERSION_MAJOR} EQUAL 4)
        add_definitions(-DOPENCV_VERSION_4)
    elseif(${OpenCV_VERSION_MAJOR} LESS 4)
        add_definitions(-DOPENCV_VERSION_3)
    endif()
else()
    message(FATAL_ERROR "OpenCV Library Not Found")
endif()

if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/cpp/amd64/)
link_directories(${PROJECT_SOURCE_DIR}/lib/cpp/amd64/)
else()
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/cpp/arm64/)
link_directories(${PROJECT_SOURCE_DIR}/lib/cpp/arm64/)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
include_directories(${PROJECT_SOURCE_DIR}/include)

set(SDKLIBS unitree_camera tstc_V4L2_xu_camera udev systemlog ${OpenCV_LIBS})





find_package(OpenGL REQUIRED)
if(OpenGL_FOUND)
    include_directories(${OPENGL_INCLUDE_DIR})
    message(STATUS ${OPENGL_INCLUDE_DIR})
    message(STATUS ${OPENGL_LIBRARIES})
else()
    message(WARNING "OpenGL Library Not Found")
endif()

find_package(GLUT REQUIRED)
if(GLUT_FOUND)
    include_directories(${GLUT_INCLUDE_DIR})
    message(STATUS ${GLUT_INCLUDE_DIR})
    message(STATUS ${GLUT_LIBRARY})
else()
    message(WARNING "GLUT Library Not Found")
endif()

find_package(X11 REQUIRED)
if(X11_FOUND)
    include_directories(${X11_INCLUDE_DIR})
    message(${X11_INCLUDE_DIR})
    message(${X11_LIBRARIES})
else()
    message(WARNING "X11 Library Not Found")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")


##########


# include_directories(include)
# add_compile_options(-std=c++14)

# check arch and os
message("-- CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64.*")
  set(ARCH amd64)
endif()
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64.*")
  set(ARCH arm64)
endif()

# link_directories(lib/cpp/${ARCH})
set(EXTRA_LIBS -pthread libunitree_legged_sdk.so)  ####

set(CMAKE_CXX_FLAGS "-O3 -fPIC ${CMAKE_CXX_FLAGS} -std=c++11 -pthread")


# one pc one process

add_executable(main src/main.cpp)
target_link_libraries(main ${EXTRA_LIBS} ${SDKLIBS})

#add_executable(main1 src/main1.cpp)
#target_link_libraries(main1 ${EXTRA_LIBS} ${SDKLIBS})

#add_executable(shot src/shot.cpp)
#target_link_libraries(shot ${SDKLIBS})

#add_executable(temp src/temp.cpp)
#target_link_libraries(temp ${SDKLIBS})

#add_executable(camera_test src/camera_test.cpp)
#target_link_libraries(camera_test ${SDKLIBS})


